<template lang="html">
  <div class="pushBox" v-loading.body="loading">
    <el-row v-for="item in $store.state.TanGoods.pushDetail.data">
      <el-col :span="2" class="text-right" style="margin-right:10px;">{{item.label}}:</el-col>
      <el-col :span="18" v-if="item.type==1" class="text-left">
        {{item.value}}
      </el-col>
      <el-col :span="12"  v-if="item.type==2" class="text-left">
        <el-input placeholder="请输入内容" v-model="item.value" size="small"></el-input>
      </el-col>
      <el-col :span="12"  v-if="item.type==3" class="text-left" style="padding-top:7px;">
        <el-input
          type="textarea"
          :rows="4"
          placeholder="请输入内容"
          v-model="item.value">
        </el-input>
      </el-col>
    </el-row>
    <!-- <el-row>
      <el-col :span="2" class="text-right">主要内容：</el-col>
      <el-col :span="15" class="text-left" style="color:#DE013C;">
        <el-input placeholder="请输入内容" size="small"></el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="2" class="text-right">预约项目：</el-col>
      <el-col :span="12" class="text-left" style="line-height:20px; padding-top:5px;">{{$store.state.TanGoods.pushDetail.productName}}</el-col>
    </el-row>
    <el-row>
      <el-col :span="2" class="text-right">预约时间：</el-col>
      <el-col :span="4" class="text-right">
        <el-date-picker
          v-model="date"
          size="small"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="2" class="text-right">取消原因：</el-col>
      <el-col :span="8" class="text-left" style="padding-top:8px;">
        <el-input
          type="textarea"
          :rows="4"
          placeholder="请输入内容"
          v-model="textarea">
        </el-input>
      </el-col>
    </el-row> -->
    <!-- <el-row>
      <el-col :span="2" class="text-right">详情链接：</el-col>
      <el-col :span="8" class="text-left">>>点击重选日期</el-col>
    </el-row> -->
    <el-row class="text-left" style="margin-top:10px;">
    <el-button type="success" size="small" @click="sub">确认推送</el-button>
    </el-row>
  </div>
</template>

<script>
import axios from "axios"
var url;
export default {
  data(){
    return {
      value:'',
      textarea:'',
      date:'',
      loading:false
    }
  },
  methods:{
    sub:function (){
      this.loading=true;
      var that = this,content='',reason='';
      var data=that.$store.state.TanGoods.pushDetail.data;
      for(let i=0;i<data.length;i++){
        if(data[i].name=='content'){
          content=data[i].value;
        }
        if(data[i].name=='reason'){
          reason=data[i].value;
        }
      }
      axios.get(url+'/v1/push/wechat',{
        params:{
          orderIds:that.$store.state.TanGoods.pushDetail.id,
          templateCode:'HDQX',
          reason:reason,
          content:content
        }
      }).then((res)=>{
        this.loading=false;
        if(res.data.code==0){
          this.$store.dispatch('closeDialog','TanGoods');
          this.$message({
            showClose: true,
            message: '发送成功',
            type: 'success'
          });
        }else{
          this.$message({
            showClose: true,
            message: res.data.msg,
            type: 'error'
          });
        }
      }).catch((err)=>{
        console.log(err);
      })
    }
  },
  created(){
    url=this.$store.state.url;
  }
}
</script>

<style lang="Sass" scoped>
.pushBox{
  span{line-height: 30px;}
  div{line-height: 30px;}
}
</style>
